package com.weiawei.Dialog;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

public class ExitDialog extends baseDialog{

    public static int exit = 1 ;
    public static int cancel = 0 ;

    private JButton exitButton , cancelButton;
    private  JLabel jLabel ;

    /**
     * exitdialog的构造函数
     * @param jFrame 容器
     * @param title  对话框标题
     * @param flag
     */
    public ExitDialog(JFrame jFrame, String title, boolean flag) {
        super(jFrame, title, flag);
        this.init();
    }

    /**
     * 初始化弹框
     * 初始化选项与内容
     */
    private  void init(){
        exitButton = new JButton("退出游戏");
        cancelButton = new JButton("取  消");
        jLabel = new JLabel();

        this.setRightButton(exitButton);
        this.setLeftButton(cancelButton);

        jLabel.setFont(new Font(Font.DIALOG_INPUT , Font.BOLD ,15 ));
        jLabel.setBounds(80,10,200,100);
        jLabel.setText("您确定要退出游戏吗？");

        add(exitButton);
        add(cancelButton);
        add(jLabel);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == cancelButton){
            message = cancel ;
            setVisible(false);
        }else if(e.getSource() == exitButton){
            message = exit ;
            setVisible(false);
        }
    }
}
